/*
 * Copyright (c) 2014 laidian. All Rights Reserved.
 * 
 * @author yaoyuming
 * 
 * @date 2020-05-25 11:04
 */
package com.yao.common.util;

import java.util.Optional;

import com.yao.common.exception.BusinessException;

import cn.hutool.core.util.StrUtil;

/**
 * 异常工具类
 * 
 * @author yaoyuming
 * @date 2020/05/25 11:04
 */
public class ThrowUtils {

    public static <T> T isNull(T t, Object message) {
        return isNull(t, "{}", message);
    }

    public static  <T> T isNull(T t, String template, Object... message) {
        return Optional.ofNullable(t).orElseThrow(() -> new BusinessException(StrUtil.format(template, message)));
    }

}